import { Component, Injector, OnInit } from '@angular/core';
import { AuditlogMessageService } from 'services/auditlog/auditlog.service';
import { AppComponentBase } from '@shared/component-base/app-component-base';
import { PagedResultDto } from '@shared/component-base/paged-listing-component-base';



@Component({
    selector: 'app-auditlog',
    templateUrl: 'auditlog.component.html',
    styles: [],
    providers: [AuditlogMessageService]
})
export class AuditlogComponent extends AppComponentBase implements OnInit {
    search: any = {};
    params: any = {};
    tableLoading = false;
    expandForm = false;
    constructor(
        injector: Injector,
        private _auditlogService: AuditlogMessageService,


    ) {
        super(injector);
    }


    ngOnInit(): void {
        this.getAuditlogAll();
    }
    //查询重置筛选
    searchlist() {
        this.query.pageIndex = 1;
        this.getAuditlogAll();
    }
    //查询
    getAuditlogAll() {
        this.tableLoading = true;

        this.params.SkipCount = this.query.skipCount();
        this.params.MaxResultCount = this.query.pageSize;
        this.params.UserName = this.search.UserName;
        this.params.ServiceName = this.search.ServiceName;
        this.params.MethodName = this.search.MethodName;
        if (this.search.ExecutionTime) {
            this.params.StartDate = this.search.ExecutionTime[0];
            this.params.EndDate = this.search.ExecutionTime[1];
        }

        // this.params.MinExecutionDuration = this.search.MinExecutionDuration;
        // this.params.MaxExecutionDuration = this.search.MaxExecutionDuration;
        this._auditlogService
            .getAll(this.params)
            .subscribe((result: PagedResultDto) => {
                this.tableLoading = false;
                this.query.dataList = result.items;
                this.query.total = result.totalCount;
            });

    }

    // 导出
    exportExcel() {
        // console.log(1111111111)
        this._auditlogService.exportFileAsync(this.params).subscribe((v) => {
            window.location.href = v
        });

    }
}
